package com.viking.utils;

public class SequenceGenerator {
	private static SequenceGenerator instance;
	private int index = 0;
	private int max = 65535;

	public static SequenceGenerator getInstance() {
		if (instance == null) {
			instance = new SequenceGenerator();
		}
		return instance;
	}

	public int getNext() {
		index++;
		if (index == max) {
			index = 0;
		}
		int tmp=index;
		return tmp;
	}

	public int getCurrent() {
		return index;
	}

	public void reSet() {
		this.index = 0;
	}

	public void setCycle(int max) {
		this.max = max;
	}
}
